package algorithm.leetcode.I801to1000;

import algorithm.leetcode.TreeNode;

/**
 * 非递归做法参照Q94
 * 递归做法
 */

public class Q897 {

    TreeNode head;
    TreeNode curr;

    public TreeNode increasingBST(TreeNode root) {
        inorderTraverse(root);
        return head;
    }

    private void inorderTraverse(TreeNode node) {
        if (node == null) return;

        inorderTraverse(node.left);
        if (head == null) head = node;
        else curr.right = node;
        curr = node;
        curr.left = null;
        inorderTraverse(node.right);
    }

}
